package com.rmfyzxfw.caseprocess.boot.result;

import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import lombok.Data;

/**
 * 通用返回对象
 * @author SUNDAY
 * @date 2021/12/29 16:49
 */
@JsonInclude(JsonInclude.Include.NON_NULL)
@Data
@ApiModel(value = "MessageVo", description = "api返回数据模型")
public class R {


    public static ApiResult fail(Integer code, String msg){
        return ApiResult.fail(code, msg);
    }

    public static ApiResult fail(CommonStatusCode statusCode, String... formatMsgValue){
        return ApiResult.fail(statusCode.getCode(), CommonStatusCode.getCodeMsg(statusCode, formatMsgValue));
    }


    public static <T> ApiResult<T> success(){
        return success(null, "操作成功！");
    }

    public static <T> ApiResult<T> success(T data){
        return success(data, "操作成功！");
    }

    public static <T> ApiResult<T> success(T data, String msg){
        return ApiResult.success(msg, data);
    }

}
